﻿using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace CloudPms.Common.LogProvider
{
    public partial class LogContext : DbContext
    {
        public LogContext()
            : this(false) { }
    
        public LogContext(bool proxyCreationEnabled)
            : base("name=LogContext")
        {
            this.Configuration.ProxyCreationEnabled = proxyCreationEnabled;
        }
    
        public LogContext(string connectionString)
          : this(connectionString, false) { }

        public LogContext(string connectionString, bool proxyCreationEnabled)
            : base(connectionString)
        {
            this.Configuration.ProxyCreationEnabled = proxyCreationEnabled;
        }	
    
    	protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //base.OnModelCreating(modelBuilder);
            
            // 移除EF的表名公约  
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            
            // 还可以移除对MetaData表的查询验证
            //modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
            //throw new UnintentionalCodeFirstException();
        }
        
        public DbSet<CommonLog> CommonLog { get; set; }
       
    }
}
